package org.hackystat.linkedservicedata.ui.users;

import java.util.HashMap;
import java.util.LinkedList;
import org.hackystat.linkedservicedata.vocabularies.HackystatVocab;

/**
 * Utility class to group all the components used to construct a user profile.
 *
 * @author Myriam Leggieri.
 *
 */
public class UserProfile {

  public String email = null;

  public String nickname = null;

  public String weblog = null;

  public String homepage = null;

  public String karma = null;

  private double developmentTime = -1;

  private double buildQuality = -1;

  private double amountOfIssues = -1;

  private double commitFrequency = -1;

  private double communicationEffort = -1;

  private HashMap<String, Double> skills = new HashMap<String, Double>();

  private LinkedList<String[]> projectsRoles = new LinkedList<String[]>();

  private LinkedList<String> seeAlso = new LinkedList<String>();

  private LinkedList<String> sameAs = new LinkedList<String>();

  public String visibility = "-1";

  public String name = null;

  public String surname = null;

  public UserProfile() {
    resetSkills();
  }

  public void resetProjectsRoles() {
    projectsRoles = new LinkedList<String[]>();
  }

  public void addProjectRole(String project, String role) {
    projectsRoles.add(new String[] { project, role });
  }

  public LinkedList<String[]> getProjectsRoles() {
    return projectsRoles;
  }

  public void resetSkills() {
    skills = new HashMap<String, Double>();
    skills.put(HackystatVocab.DEVELOPMENT_TIME.getLocalName(), Double.valueOf(-1));
    skills.put(HackystatVocab.AMOUNT_OF_CODE_ISSUES.getLocalName(), Double.valueOf(-1));
    skills.put(HackystatVocab.BUILD_QUALITY.getLocalName(), Double.valueOf(-1));
    skills.put(HackystatVocab.COMMIT_FREQUENCY.getLocalName(), Double.valueOf(-1));
    skills.put(HackystatVocab.COMMUNICATION_EFFORT.getLocalName(), Double.valueOf(-1));
  }

  public HashMap<String, Double> getSkills() {
    return skills;
  }

  public void setDevelopmentTime(double developmentTime) {
    this.developmentTime = developmentTime;
    String key = HackystatVocab.DEVELOPMENT_TIME.getLocalName();
    Double tmp = skills.get(key);
    tmp = Double.valueOf(developmentTime);
    skills.remove(key);
    skills.put(key, tmp);
  }

  public double getDevelopmentTime() {
    return developmentTime;
  }

  public void setBuildQuality(double buildQuality) {
    this.buildQuality = buildQuality;
    String key = HackystatVocab.BUILD_QUALITY.getLocalName();
    Double tmp = skills.get(key);
    tmp = Double.valueOf(buildQuality);
    skills.remove(key);
    skills.put(key, tmp);
  }

  public double getBuildQuality() {
    return buildQuality;
  }

  public void setAmountOfIssues(double amountOfIssues) {
    this.amountOfIssues = amountOfIssues;
    String key = HackystatVocab.AMOUNT_OF_CODE_ISSUES.getLocalName();
    Double tmp = skills.get(key);
    tmp = Double.valueOf(amountOfIssues);
    skills.remove(key);
    skills.put(key, tmp);
  }

  public double getAmountOfIssues() {
    return amountOfIssues;
  }

  public void setCommitFrequency(double commitFrequency) {
    this.commitFrequency = commitFrequency;
    String key = HackystatVocab.COMMIT_FREQUENCY.getLocalName();
    Double tmp = skills.get(key);
    tmp = Double.valueOf(commitFrequency);
    skills.remove(key);
    skills.put(key, tmp);
  }

  public double getCommitFrequency() {
    return commitFrequency;
  }

  public void resetSeeAlso() {
    seeAlso = new LinkedList<String>();
  }

  public void addSeeAlsoUri(String uri) {
    seeAlso.add(uri);
  }

  public LinkedList<String> getSeeAlso() {
    return seeAlso;
  }

  public void resetSameAs() {
    sameAs = new LinkedList<String>();
  }

  public void addSameAsUri(String uri) {
    sameAs.add(uri);
  }

  public LinkedList<String> getSameAs() {
    return sameAs;
  }

  public void setCommunicationEffort(double communicationEffort) {
    this.communicationEffort = communicationEffort;
    String key = HackystatVocab.COMMUNICATION_EFFORT.getLocalName();
    Double tmp = skills.get(key);
    tmp = Double.valueOf(communicationEffort);
    skills.remove(key);
    skills.put(key, tmp);
  }

  public double getCommunicationEffort() {
    return communicationEffort;
  }
}
